import type { ResultData } from '@/types/commonType'
import type { EditParams, Params, RoleItem, CreateParams, CreatePermission } from '@/types/roleType'
import request from '@/utils/request'

export default {
  // 获取所有角色
  getRoleAllList() {
    return request.get<RoleItem[]>('/roles/allList', {})
  },
  // 获取角色列表
  getRoleList(params: Params) {
    return request.get<ResultData<RoleItem>>('/roles/list', params)
  },
  // 创建角色
  createRole(params: CreateParams) {
    return request.post('/roles/create', params)
  },
  // 修改角色
  editRole(params: EditParams) {
    return request.post('/roles/edit', params)
  },
  // 删除角色
  delRoleById(params: { _id: string }) {
    return request.post('/roles/delete', params)
  },
  // 更新权限
  updatePermission(params: CreatePermission) {
    return request.post('/roles/update/permission', params)
  }
}
